import request from "@/utils/request";

// 公告列表 /Category/:page
export const getCategoryList = () => {
    return request({
        url: `/category`,
        method: "get",
    });
};

// 新增 /Category
export const addCategory = (data: object) => {
    return request({
        url: `/category`,
        method: "post",
        data
    });
};
// 修改
export const editCategory = (id: number, data: object) => {
    return request({
        url: `/category/${id}`,
        method: "post",
        data
    });
};
// 删除
export const delCategory = (id: number) => {
    return request({
        url: `/category/${id}/delete`,
        method: "post",
    });
};

// 修改状态 /rule/:id/update_status
export const changStatus = (id: number, data: object) => {
    return request({
        url: `/category/${id}/update_status`,
        method: "POST",
        data,
    });
};

// 关联列表 

export const getCategoryGoods = (id: number) => {
    return request({
        url: `app_category_item/list?category_id=${id}`,
        method: "GET",
    });
};
// 删除关联 app_category_item/:id/delete

export const delCategoryGoods = (id: number) => {
    return request({
        url: `app_category_item/${id}/delete`,
        method: "post",
    });
};

// 添加关联产品
export const addCategoryGoods = (data: object) => {
    return request({
        url: `app_category_item`,
        method: "post",
        data
    });
};